package com.xlf.service.base.controller.admin;

import com.xlf.common.core.pojo.mode.AjaxResult;
import com.xlf.common.core.pojo.mode.BaseController;
import com.xlf.pojo.base.Difficulty;
import com.xlf.pojo.base.Tag;
import com.xlf.service.base.service.DifficultyService;
import com.xlf.service.base.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author xlf 2734029211@qq.com
 * @Date 2023/11/23 10:14
 * @Description: TODO 标签管理
 * @Version 1.0
 */
@RestController
@RequestMapping("/base/admin/tag")
public class AdminTagController extends BaseController {

    @Autowired
    TagService tagService;

    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('base:admin:tag:list')")
    public AjaxResult list(Tag tag){
        startPage();
        return success(getDataTable(tagService.getList(tag)));
    }

    @PostMapping("/saveOrUpdate")
    @PreAuthorize("@ss.hasPermi('base:admin:tag:saveOrUpdate')")
    public AjaxResult saveOrUpdate(@RequestBody Tag tag){
        return success(tagService.saveOrUpdate(tag));
    }


    @GetMapping("/query/{id}")
    @PreAuthorize("@ss.hasPermi('base:admin:tag:query')")
    public AjaxResult query(@PathVariable(value = "id") String id){
        return success(tagService.getById(id));
    }

    @DeleteMapping("/delete")
    @PreAuthorize("@ss.hasPermi('base:admin:tag:delete')")
    public AjaxResult delete(@RequestBody List<String> ids){
        tagService.delete(ids);
        return success("删除成功！");
    }

    @PutMapping("/disabled")
    @PreAuthorize("@ss.hasPermi('base:admin:tag:saveOrUpdate')")
    public AjaxResult updateStatus(@RequestBody Tag tag){
        return success(tagService.updateStatus(tag));
    }

}
